Skip to content

entry for wiener diffusion model#934

Open
Franzi2114 wants to merge 2 commits intostan-dev:masterfrom
Franzi2114:feature/docs_for_wiener_lpdf_and_lcdf_unnorm
Open

entry for wiener diffusion model#934
Franzi2114 wants to merge 2 commits intostan-dev:masterfrom
Franzi2114:feature/docs_for_wiener_lpdf_and_lcdf_unnorm

Conversation

@Franzi2114
Copy link
Copy Markdown
Contributor

Summary

This PR adds a user's guide entry for the wiener diffusion model. It is linked to the PRs for the seven parameter diffusion model PDF and CDF functions
stan-dev/math#2822
stan-dev/math#3042

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):

Franziska Henrich

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@bob-carpenter
Copy link
Copy Markdown
Member

Thanks, so much, @Franzi2114. If nobody else can get to this, I can review it some time over the next week.

@Franzi2114
Copy link
Copy Markdown
Contributor Author

Perfec,t thanks @bob-carpenter! I was also in contact with @WardBrian before I did the PR.

There are still three open points that I didn't manage to incorporate:

  • The citations did not work locally although I added the entries in the bib file
  • I would prefer to include the .pdf version instead of the .jpeg version of the image as it has much higher quality
  • and there could be inserted a link to another subchapter of the User’s guide.

Please let me know when there occur more points that I should change.

@WardBrian WardBrian requested a review from bob-carpenter March 12, 2026 11:12
@WardBrian
Copy link
Copy Markdown
Member

Hi @Franzi2114 --

I've just pushed a commit that addresses each of your comments, since they're mostly quarto-wrangling:

  • The citations issue seems to have just been a small typo.
  • Quarto supports multi-format figures, so as it is currently written the website will use the JPG and the pdf manual will use the PDF. If you have a higher-quality raster image (png, nicer jpg, etc) we can use that on the web version instead
  • I added the link and made sure that this new chapter shows up on the sidebar.

@WardBrian
Copy link
Copy Markdown
Member

Pinging @bob-carpenter again -- I think the notifications for this got lost while you were away

@bob-carpenter
Copy link
Copy Markdown
Member

Thanks for pinging. I will review this week.

Copy link
Copy Markdown
Member

@bob-carpenter bob-carpenter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Franzi:

I'm really sorry this is so many comments. Most of it's to try to get consistency with the rest of our documentation's formatting.

The most important comment is about the upper bounds for parameters that are missing from the examples.

If you'd rather not make the fixes yourself, I think I can go through and make almost all of them other than places where I had genuine questions.

Comment thread src/bibtex/all.bib

@article{Henrich2026,
author={Henrich, Franziska and Klauer, Karl Christoph},
title={Modeling truncated and censored data with the diffusion model in Stan},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitals in titles need to be escaped, so

Stan -> {S}tan

in the title.

Comment thread src/bibtex/all.bib
@article{Wagenmakers2009,
author = {Wagenmakers, Eric-Jan},
year = {2009},
title = {{Methodological and empirical developments for the Ratcliff diffusion model of response times and accuracy}},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only escape the unusual caps, so that BibTeX can style. This should not have the outer braces and just curly braces around the R in Ratcliff.

Comment thread src/bibtex/all.bib
volume = {21},
number = {5},
issn = {0954-1446},
journal = {{European Journal of Cognitive Psychology}},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No double braces. BibTeX styles sort out which style of capitalization and we only need to provide hints about things that should always be capitalized by wrapping in curly braces.

Comment thread src/bibtex/all.bib
@article{Ulrich1994,
author = {Ulrich, Rolf and Miller, Jeff},
year = {1994},
title = {{Effects of truncation on reaction time analysis}},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No double braces.

Comment thread src/bibtex/all.bib
pages = {34--80},
volume = {123},
number = {1},
journal = {{Journal of Experimental Psychology: General}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No double braces.

Censoring sometimes includes the response (i.e., it is known that the reaction time in a trial fell outside the response window, but which response was given is unknown). One method that has been used to model such data has involved inferring the numbers of missing responses of either kind from the observed relative frequencies of the two responses. This approach has the problem that quite specifc assumptions on the missing data have to be made (namely, that the proportions of the two kinds of responses are the same for responses within and outside the response window).

Here is a more principled approach that uses the cumulative distribution functions and their complements to provide the likelihood of censored data. As before, let $L$ be the left reaction time bound, and $U$ the right reaction time bound, and consider decision times without inter-trial variabilities for the sake of simplicity. It follows that the likelihood $p_l$ of observing a left-censored data point
is given by
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite the right usage of "likelihood". See:

https://statmodeling.stat.columbia.edu/2026/03/20/a-data-model-is-not-just-a-likelihood/

If we have a data-generating distribution $p(y \mid \theta)$, then if we fix $\theta$, we get a density for $y$. If we fix $y = y^\text{obs}$, we get the likelihood function $\mathcal{L}(\theta) = p(y^\text{obs} \mid \theta)$.

Specifically, this means we can't say "likelihood of data" as the likelihood function, in order to exist, has already fixed the data.

This is confused in the literature all over the place, but BDA makes it clear, as does Aki's post.



See the following code for an example of Stan code implementing this second case of censoring. This model call deals with the problem of unknown responses by computing the probability of choosing the response-1- or response-0 boundary outside the response window. Here, the CDF and/or the CCDF are required, depending upon whether there is only left-censoring, right-censoring, or censoring both to the left and to the right. The following code shows the **functions block** for a model that is right-censored using the function `partial_sum_wiener()` for parallel computations. Combine this block with the **model block** in the example above:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

he block doesn't actually show any parallel computations, so either get rid of this or say a bit more about what would be required.

See the following code for an example of Stan code implementing this second case of censoring. This model call deals with the problem of unknown responses by computing the probability of choosing the response-1- or response-0 boundary outside the response window. Here, the CDF and/or the CCDF are required, depending upon whether there is only left-censoring, right-censoring, or censoring both to the left and to the right. The following code shows the **functions block** for a model that is right-censored using the function `partial_sum_wiener()` for parallel computations. Combine this block with the **model block** in the example above:

```stan
functions { // parallelization function
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what "parallelization function" refers to here---whatever it is, it shouldn't be a comment on the functions block.

I take it you mean that the partial_sum_wiener function could be used in reduce_sum? If so, it would help to say so somewhere.

```stan
functions { // parallelization function
real partial_sum_wiener(array[] real rt_slice, int start,
int end, real a, real t0, real w, real v, real sv, real sw,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent the second and third line of arguments under the first arguments.

two spaces indent everywhere

return ans;
} // end partial_sum_fullddm
} // end functions
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the earlier functions, a transformed data block that sorted the three types of data would allow vectorization and allow the censoring parts to be replaced. with a product given that the right bound doesn't change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants